/* CSP-201312P5 I’m stuck!
求两类目标方格的数量：
1. 玩家可以从初始位置移动到此方格；
——从S开始用DFS或BFS都可以实现。
2. 玩家不可以从此方格移动到目标位置。
——从S能到这个方格，属于1类点。
——但不能到达T：直接算不容易，但是从T出发反向搜索能确定所有可达T的1类点，剩余1类点就是第二问答案。
*/
#include<algorithm>
#include<climits>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<list>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;

void visit(vector<vector<char> > &m, vector<vector<int> > &v, int r, int c){
  if(r < 0 || r >= m.size() || c < 0 || c >= m[0].size() || m[r][c] == '#' || v[r][c]){
    return;
  }
  v[r][c] = 1;
  switch(m[r][c]){
  case 'S':
  case '+':
  case 'T': visit(m, v, r-1, c); visit(m, v, r+1, c); visit(m, v, r, c-1); visit(m, v, r, c+1); break;
  case '-': visit(m, v, r, c-1); visit(m, v, r, c+1); break;
  case '|': visit(m, v, r-1, c); visit(m, v, r+1, c); break;
  case '.': visit(m, v, r+1, c); break;
  }
}

/*
dfs reversily!
*/
void dfs(vector<vector<char> > &m, vector<vector<int> > &v, int r, int c){
  if(r < 0 || r >= m.size() || c < 0 || c >= m[0].size() || m[r][c] == '#' || v[r][c] != 1){
    return;
  }
  v[r][c] = 2;
  if(r > 0 && (m[r-1][c] == 'S' || m[r-1][c] == '+' ||m[r-1][c] == '|' ||m[r-1][c] == 'T' ||m[r-1][c] == '.')){
    dfs(m, v, r-1, c);
  }
  if(r < m.size()-1 && (m[r+1][c] == 'S' || m[r+1][c] == '+' ||m[r+1][c] == '|' ||m[r+1][c] == 'T')){
    dfs(m, v, r+1, c);
  }
  if(c > 0 && (m[r][c-1] == 'S' || m[r][c-1] == '+' ||m[r][c-1] == '-' ||m[r][c-1] == 'T')){
    dfs(m, v, r, c-1);
  }
  if(c < m[0].size()-1 && (m[r][c+1] == 'S' || m[r][c+1] == '+' ||m[r][c+1] == '-' ||m[r][c+1] == 'T')){
    dfs(m, v, r, c+1);
  }
}

int main(){
  // 201312-5: I’m stuck!
  int R = 0, C = 0;
  cin >> R >> C;
  vector<vector<char> > m(R); // map
  vector<vector<int> > v(R); // visit-flag
  int sr = 0, sc = 0;
  int tr = 0, tc = 0;
  for(int r = 0; r < R; ++r){
    m[r].resize(C);
    v[r].resize(C);
    for(int c = 0; c < C; ++c){
      cin >> m[r][c];
      if(m[r][c] == 'S'){ sr = r; sc = c; }
      if(m[r][c] == 'T'){ tr = r; tc = c; }
    }
  }

  visit(m, v, sr, sc);
  if(v[tr][tc] == 0){
    cout << "I'm stuck!" << endl;
    return 0;    
  }

  dfs(m, v, tr, tc);

  int x = 0;
  for(int r = 0; r < R; ++r){
  for(int c = 0; c < C; ++c){
    if(v[r][c] == 1){ // reachable but not targetable
      ++x;
    }
  }}
  cout << x << endl;
  return 0;
}
